import sys

from PyQt5 import QtCore
from PyQt5.QtWidgets import QApplication, QMainWindow, QStackedWidget, QWidget, QVBoxLayout, QPushButton, QLabel


class PageTwo(QWidget):
    page_size = QtCore.pyqtSignal(int)

    def __init__(self, parent=None):
        super(PageTwo, self).__init__(parent)
        self.init_ui()

    def init_ui(self):
        layout = QVBoxLayout()
        label = QLabel("哈哈哈，我是第二页。。。。。")
        btn = QPushButton('Go to Page One')
        btn.clicked.connect(self.go_to_page_one)
        layout.addWidget(label)
        layout.addWidget(btn)
        self.setLayout(layout)

    def go_to_page_one(self):
        # 同上，需要实现这部分逻辑
        # self.parent().stackedWidget.setCurrentIndex(1)
        self.page_size.emit(0)
        pass  # 需要实现这部分逻辑